/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.matrimony.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.matrimony.model.ProfileKeyValue;
import com.matrimony.model.ProfileKeyValueModel;

import com.matrimony.service.persistence.ProfileKeyValuePK;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the ProfileKeyValue service. Represents a row in the &quot;matrimony_profile_key&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.matrimony.model.ProfileKeyValueModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ProfileKeyValueImpl}.
 * </p>
 *
 * @author matrimony
 * @see ProfileKeyValueImpl
 * @see com.matrimony.model.ProfileKeyValue
 * @see com.matrimony.model.ProfileKeyValueModel
 * @generated
 */
public class ProfileKeyValueModelImpl extends BaseModelImpl<ProfileKeyValue>
	implements ProfileKeyValueModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a profile key value model instance should use the {@link com.matrimony.model.ProfileKeyValue} interface instead.
	 */
	public static final String TABLE_NAME = "matrimony_profile_key";
	public static final Object[][] TABLE_COLUMNS = {
			{ "profileId", Types.BIGINT },
			{ "keyId", Types.BIGINT },
			{ "valueId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table matrimony_profile_key (profileId LONG not null,keyId LONG not null,valueId LONG not null,primary key (profileId, keyId, valueId))";
	public static final String TABLE_SQL_DROP = "drop table matrimony_profile_key";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.matrimony.model.ProfileKeyValue"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.matrimony.model.ProfileKeyValue"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.matrimony.model.ProfileKeyValue"),
			true);
	public static long KEYID_COLUMN_BITMASK = 1L;
	public static long PROFILEID_COLUMN_BITMASK = 2L;
	public static long VALUEID_COLUMN_BITMASK = 4L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.matrimony.model.ProfileKeyValue"));

	public ProfileKeyValueModelImpl() {
	}

	public ProfileKeyValuePK getPrimaryKey() {
		return new ProfileKeyValuePK(_profileId, _keyId, _valueId);
	}

	public void setPrimaryKey(ProfileKeyValuePK primaryKey) {
		setProfileId(primaryKey.profileId);
		setKeyId(primaryKey.keyId);
		setValueId(primaryKey.valueId);
	}

	public Serializable getPrimaryKeyObj() {
		return new ProfileKeyValuePK(_profileId, _keyId, _valueId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((ProfileKeyValuePK)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return ProfileKeyValue.class;
	}

	public String getModelClassName() {
		return ProfileKeyValue.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("profileId", getProfileId());
		attributes.put("keyId", getKeyId());
		attributes.put("valueId", getValueId());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long profileId = (Long)attributes.get("profileId");

		if (profileId != null) {
			setProfileId(profileId);
		}

		Long keyId = (Long)attributes.get("keyId");

		if (keyId != null) {
			setKeyId(keyId);
		}

		Long valueId = (Long)attributes.get("valueId");

		if (valueId != null) {
			setValueId(valueId);
		}
	}

	public long getProfileId() {
		return _profileId;
	}

	public void setProfileId(long profileId) {
		_columnBitmask |= PROFILEID_COLUMN_BITMASK;

		if (!_setOriginalProfileId) {
			_setOriginalProfileId = true;

			_originalProfileId = _profileId;
		}

		_profileId = profileId;
	}

	public long getOriginalProfileId() {
		return _originalProfileId;
	}

	public long getKeyId() {
		return _keyId;
	}

	public void setKeyId(long keyId) {
		_columnBitmask |= KEYID_COLUMN_BITMASK;

		if (!_setOriginalKeyId) {
			_setOriginalKeyId = true;

			_originalKeyId = _keyId;
		}

		_keyId = keyId;
	}

	public long getOriginalKeyId() {
		return _originalKeyId;
	}

	public long getValueId() {
		return _valueId;
	}

	public void setValueId(long valueId) {
		_columnBitmask |= VALUEID_COLUMN_BITMASK;

		if (!_setOriginalValueId) {
			_setOriginalValueId = true;

			_originalValueId = _valueId;
		}

		_valueId = valueId;
	}

	public long getOriginalValueId() {
		return _originalValueId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ProfileKeyValue toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (ProfileKeyValue)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		ProfileKeyValueImpl profileKeyValueImpl = new ProfileKeyValueImpl();

		profileKeyValueImpl.setProfileId(getProfileId());
		profileKeyValueImpl.setKeyId(getKeyId());
		profileKeyValueImpl.setValueId(getValueId());

		profileKeyValueImpl.resetOriginalValues();

		return profileKeyValueImpl;
	}

	public int compareTo(ProfileKeyValue profileKeyValue) {
		ProfileKeyValuePK primaryKey = profileKeyValue.getPrimaryKey();

		return getPrimaryKey().compareTo(primaryKey);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		ProfileKeyValue profileKeyValue = null;

		try {
			profileKeyValue = (ProfileKeyValue)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		ProfileKeyValuePK primaryKey = profileKeyValue.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		ProfileKeyValueModelImpl profileKeyValueModelImpl = this;

		profileKeyValueModelImpl._originalProfileId = profileKeyValueModelImpl._profileId;

		profileKeyValueModelImpl._setOriginalProfileId = false;

		profileKeyValueModelImpl._originalKeyId = profileKeyValueModelImpl._keyId;

		profileKeyValueModelImpl._setOriginalKeyId = false;

		profileKeyValueModelImpl._originalValueId = profileKeyValueModelImpl._valueId;

		profileKeyValueModelImpl._setOriginalValueId = false;

		profileKeyValueModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<ProfileKeyValue> toCacheModel() {
		ProfileKeyValueCacheModel profileKeyValueCacheModel = new ProfileKeyValueCacheModel();

		profileKeyValueCacheModel.profileId = getProfileId();

		profileKeyValueCacheModel.keyId = getKeyId();

		profileKeyValueCacheModel.valueId = getValueId();

		return profileKeyValueCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{profileId=");
		sb.append(getProfileId());
		sb.append(", keyId=");
		sb.append(getKeyId());
		sb.append(", valueId=");
		sb.append(getValueId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("com.matrimony.model.ProfileKeyValue");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>profileId</column-name><column-value><![CDATA[");
		sb.append(getProfileId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>keyId</column-name><column-value><![CDATA[");
		sb.append(getKeyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>valueId</column-name><column-value><![CDATA[");
		sb.append(getValueId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = ProfileKeyValue.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			ProfileKeyValue.class
		};
	private long _profileId;
	private long _originalProfileId;
	private boolean _setOriginalProfileId;
	private long _keyId;
	private long _originalKeyId;
	private boolean _setOriginalKeyId;
	private long _valueId;
	private long _originalValueId;
	private boolean _setOriginalValueId;
	private long _columnBitmask;
	private ProfileKeyValue _escapedModelProxy;
}